
	<!DOCTYPE html>
	<html>
		<head>
			<meta charset="UTF-8">
			<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
			<title>发货列表</title>
			<link rel="stylesheet" href="css/AllStyle.css" />
			<link rel="stylesheet" href="css/iconfont.css" />
			<script type="text/javascript" src="js/common.js" ></script>
			<script type="text/javascript" src="js/companydata.js" ></script>
<!--			  <script type="text/javascript" src="js/loadData.js" ></script>-->
			<script type="text/javascript" src="js/data.js" ></script>
			<script type="text/javascript" src="js/tmpl.js" ></script>
		</head>
		<body>
			<!-- 页头 -->
			<section>
				<script type="text/javascript">
					AllPageHeader()
				</script>
			</section>

			<section class="AllContent" id="AllContent">
				<div id="sendList">
					<img style="width: 40%;margin:20px auto;display: block;" src="images/loading5.gif">
				</div>

			</section>

			<div id="dddd"></div>
		</body>
		<script type="text/javascript" src="js/jquery.min.js" ></script>
		<script type="text/javascript" src="js/mui.min.js" ></script>
		<script type="text/javascript">
			mui.init();

			mui.back = function() {
			    mui.openWindow({
			    	url: 'supper.html',
			    	id:'supper.html'
			    });
			}

			//搜索客户发货单
			$(".serarchBtn").on('tap',function(){
			  querySend();
			});

			$(function(){
				if(getCookie("token") === null || getCookie("token") === ''){
					window.location.href='login.html';
					return;
				}
				$('.AllHeader li:eq(1)').text('工序列表')
				$.ajax({
					headers:{
						"X-Access-Token":getCookie("token")
					},
					type: "GET",
					url: getServerUrl()+"/procedure/proc/list", //与此php页
					dataType: 'json', //从php返回的值以 JSON方式 解释
					contentType: 'application/json',
					data: 'pageSize=20'+'&pageNo=1', //
					success: function (json) {//如果调用php成功
						sendlist = json.result.records;
						var chtml = '';
						//var chtml = '';
						if (!empty(sendlist)) {
							chtml = '<ul>';
							for (var i = 0; i < sendlist.length; i++) {
								if (!empty(sendlist[i])) {
									chtml = chtml + '<li>';
									// chtml = chtml + '<a href="taskList.html?procId=' + sendlist[i].id + '">';
									chtml = chtml + '<a onclick="taskList(\''+ sendlist[i].id +'\')">';
									chtml = chtml + '<div class="ProductsListContent">';
									chtml = chtml + '<div class="ProductsDetails">';
									chtml = chtml + '<p style="font-size: 20px;">' + sendlist[i].name + '</p>';

									chtml = chtml + '</div>';
									chtml = chtml + '</div>';
									chtml = chtml + '</a>';
									chtml = chtml + '</li>';

								}
							}
							chtml = chtml + '</ul>';
						}
						$("#sendList").html(chtml);
						showpage(json.total_results,json.page_no,json.page_size,getwindowhref());
					},
					error:function(json){
						window.location.href='login.html';
					}
				});
				var RequestTime=1,page_no=1,cishu=1,intZh=1,ptinfo=1;
				$("#AllContent").scroll(function(){
					var divHeight = $(this).height();
					var nScrollHeight = $(this)[0].scrollHeight;
					var nScrollTop = $(this)[0].scrollTop;
					var xiami = nScrollTop + divHeight;
					if(nScrollTop + divHeight >= nScrollHeight) {

						if(page_no == 1){
							var Pages = 2;
						}else{
							Pages = ++page_no
						}

						if(RequestTime == cishu){
							$('#sendList').append("<img id='LoadingImg' style='borderTop:3px solid #f3f3f3;width: 20%;margin:0px auto;display: block;' src='images/loading5.gif'><p style='text-align:center;color:#777;padding:0px 0px;'>正在加载...</p>");
							$(this).animate({scrollTop:xiami},800);
							RequestTime++;
							$.ajax({
								headers:{
									"X-Access-Token":getCookie("token")
								},
								type: "GET",
								url: getServerUrl()+"/procedure/proc/list", //与此php页
								dataType: 'json', //从php返回的值以 JSON方式 解释
								contentType: 'application/json',
								data: 'pageSize=20'+'&pageNo='+Pages, //
								success: function (json) {//如果调用php成功
									sendlist = json.result.records;
									var ZLength = json.total/20;
									if(ZLength<1){
										RequestTime = 0;
										console.log(ZLength);
										return false;
									}
									UpwardRefresh(sendlist);
									showpage(json.total,0,20,getwindowhref());
									page_no = 0;
									cishu = 0;
									var ZLength = json.total/20;
									var Strlength = ZLength.toString();

									if(Strlength.substring(1)){
										intZh = Strlength.substring(0,1);
										console.log(intZh);
										intZh++;

									}
									if(0> ZLength){
										RequestTime = 0;
									}

								},
								error:function(json){
									alertMessage(json.errordescription);
								}
							});
						}else if(RequestTime == 0){
							if(ptinfo == 1){
								$('#sendList').append("<img id='LoadingImg' style='borderTop:3px solid #f3f3f3;width: 20%;margin:0px auto;display: block;' src='images/loading5.gif'><p style='text-align:center;color:#777;padding:0px 0px;'>正在加载...</p>");
								$(this).animate({scrollTop:xiami},800);

								setTimeout(function () {
									$('#LoadingImg').attr('src','images/loading5_.jpg');
									$('#LoadingImg').next().text('没有更多数据...');
								}, 1500);

								setTimeout(function () {
									$('#LoadingImg').next().hide(500);
									$('#LoadingImg').hide(500);
								}, 2500);

								ptinfo++;
							}
						}

					}
				});

			})

			function querySend() {
				var q = $("#query").val();
				var product = false;
				if (empty(q)) {
				   alertMessage("请输入客户名称");
				} else {
					$.ajax({
						type: "post",
						url: getServerUrl() + "/almes/admin/manufacture/deliveryMain/listData",
						dataType: 'json',
						data: 'customerName='+q,
						success: function (json) {
							sendlist = json.rows;
							showProduct(sendlist);
							showpage(json.total,1,20,getwindowhref());
						},
						error: function () {
							alertMessage(L('Please_check_network_connection'));
						}
					});

				}
				var oTxt=document.getElementById("query");
				oTxt.value="";
			}

			function UpwardRefresh(sendList) {
				var chtml = '';
				//var chtml = '';
				if (!empty(sendList)) {
					for (var i = 0; i < sendList.length; i++) {
						if (!empty(sendlist[i])) {
							chtml = chtml + '<div class="ProductsListContent">';
							chtml = chtml + '<div class="ProductsDetails">';
							chtml = chtml + '<p>工序单号：' + sendList[i].code + '</p>';
							chtml = chtml + '<p>工序名称：' + sendList[i].name + '</p>';
							chtml = chtml + '</li>';
							chtml = chtml + '</ul>';
							chtml = chtml + '</div>';

							chtml = chtml + '<div class="moreOperation">';
							chtml = chtml + '<p><a href="taskList.html?id=' + sendList[i].id + '" >报工</a></p>';
							chtml = chtml + '</div>';
							chtml = chtml + '</div>';
						}
					}
				}
				$('#LoadingImg').next().remove();
				$('#LoadingImg').remove();
				$("#sendList").append(chtml);
			}



			function removeSend(id) {
				var r = confirm("请确认是否撤消发货?")
				if (r === true)
				{
					$.ajax({
						type: "post",
						url: getServerUrl() + "/almes/admin/manufacture/deliveryMain/revoke",
						dataType: 'json',
						data:'id=' + id,
						success: function (json) {
							if (json.statusCode == "200") {
								alertMessage("撤消成功！");
								loadSendList();
							} else {
								alertMessage("撤消失败:[" + json.message + "]");
							}
						}
					});
				}

			}
			function taskList(procId) {
				mui.openWindow({
					url:'taskList.html?procId='+procId,
					id:'taskList.html'
				})
			}
		</script>
	</html>
